<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>用户管理 - 北极星后台</title>
  <style>
    /* 基础样式 */
    :root {
      --primary-color: #3498db;
      --primary-light: rgba(52, 152, 219, 0.1);
      --secondary-color: #2c3e50;
      --danger-color: #e74c3c;
      --success-color: #2ecc71;
      --warning-color: #f39c12;
      --info-color: #1abc9c;
      --light-color: #ecf0f1;
      --dark-color: #34495e;
      --sidebar-width: 250px;
      --transition-speed: 0.3s;
    }

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }

    body {
      background-color: #f5f7fa;
      color: #333;
      line-height: 1.6;
    }

    /* 按钮样式 */
    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 10px 20px;
      border-radius: 6px;
      border: none;
      cursor: pointer;
      font-size: 14px;
      font-weight: 500;
      transition: all var(--transition-speed);
      gap: 8px;
    }

    .btn-primary {
      background-color: var(--primary-color);
      color: white;
    }

    .btn-outline-primary {
      background-color: transparent;
      color: var(--primary-color);
      border: 1px solid var(--primary-color);
    }

    .btn-danger {
      background-color: var(--danger-color);
      color: white;
    }

    .btn-success {
      background-color: var(--success-color);
      color: white;
    }

    .btn-warning {
      background-color: var(--warning-color);
      color: white;
    }

    .btn-info {
      background-color: var(--info-color);
      color: white;
    }

    .btn-secondary {
      background-color: #95a5a6;
      color: white;
    }

    .btn-sm {
      padding: 8px 12px;
      font-size: 13px;
    }

    .btn:hover {
      opacity: 0.9;
      transform: translateY(-2px);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .btn:active {
      transform: translateY(0);
    }

    .btn-outline-primary:hover {
      background-color: var(--primary-light);
    }

    /* 卡片样式 */
    .card {
      background-color: white;
      border-radius: 10px;
      box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
      margin-bottom: 20px;
      overflow: hidden;
      transition: all var(--transition-speed);
    }

    .card:hover {
      box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    }

    .card-header {
      padding: 18px 25px;
      border-bottom: 1px solid #eee;
      display: flex;
      justify-content: space-between;
      align-items: center;
      background-color: #f8f9fa;
    }

    .card-header h3 {
      font-size: 20px;
      color: var(--secondary-color);
      font-weight: 600;
    }

    .card-body {
      padding: 25px;
    }

    /* 顶部导航 */
    .top-nav {
      display: flex;
      justify-content: space-between;
      align-items: center;
      background-color: white;
      padding: 15px 25px;
      border-radius: 8px;
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
      margin-bottom: 20px;
    }

    .user-info {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .user-info img {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      object-fit: cover;
    }

    .user-info span {
      font-weight: 500;
    }

    /* 表格样式 */
    .table-responsive {
      width: 100%;
      overflow-x: auto;
    }

    .table {
      width: 100%;
      border-collapse: collapse;
      margin-bottom: 20px;
    }

    .table th, .table td {
      padding: 15px;
      text-align: left;
      border-bottom: 1px solid #eee;
    }

    .table th {
      font-weight: 600;
      color: var(--secondary-color);
      background-color: #f8f9fa;
    }

    .table tr:hover {
      background-color: rgba(52, 152, 219, 0.05);
    }

    .user-avatar {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .user-avatar img {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      object-fit: cover;
    }

    /* 徽章样式 */
    .badge {
      display: inline-block;
      padding: 5px 10px;
      font-size: 12px;
      font-weight: 600;
      line-height: 1;
      text-align: center;
      white-space: nowrap;
      vertical-align: middle;
      border-radius: 20px;
    }

    .badge-primary {
      background-color: var(--primary-color);
      color: white;
    }

    .badge-success {
      background-color: var(--success-color);
      color: white;
    }

    .badge-warning {
      background-color: var(--warning-color);
      color: white;
    }

    .badge-danger {
      background-color: var(--danger-color);
      color: white;
    }

    .badge-info {
      background-color: var(--info-color);
      color: white;
    }

    /* 操作按钮组 */
    .action-buttons {
      display: flex;
      gap: 8px;
    }

    /* 搜索和筛选区域 */
    .table-toolbar {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20px;
      flex-wrap: wrap;
      gap: 15px;
    }

    .search-box {
      position: relative;
      flex: 1;
      min-width: 250px;
      max-width: 400px;
    }

    .search-box input {
      width: 100%;
      padding: 10px 15px 10px 40px;
      border: 1px solid #ddd;
      border-radius: 6px;
      font-size: 14px;
      transition: all var(--transition-speed);
    }

    .search-box input:focus {
      border-color: var(--primary-color);
      box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
      outline: none;
    }

    .search-box i {
      position: absolute;
      left: 15px;
      top: 50%;
      transform: translateY(-50%);
      color: #95a5a6;
    }

    .filter-group {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
    }

    .filter-select {
      padding: 10px 15px;
      border: 1px solid #ddd;
      border-radius: 6px;
      font-size: 14px;
      background-color: white;
      cursor: pointer;
    }

    /* 分页样式修复 */
    .pagination {
      display: flex;
      justify-content: center;
      margin-top: 30px;
      list-style: none;
      padding: 0;
    }

    .pagination ul {
      display: flex;
      gap: 5px;
      margin: 0;
      padding: 0;
      list-style: none;
    }

    .page-item {
      margin: 0;
    }

    .page-link {
      display: flex;
      align-items: center;
      justify-content: center;
      min-width: 40px;
      height: 40px;
      padding: 0 15px;
      border: 1px solid #ddd;
      border-radius: 6px;
      color: var(--secondary-color);
      text-decoration: none;
      transition: all var(--transition-speed);
      font-size: 14px;
    }

    .page-link:hover {
      background-color: #f8f9fa;
      border-color: #ccc;
    }

    .page-item.active .page-link {
      background-color: var(--primary-color);
      color: white;
      border-color: var(--primary-color);
    }

    .page-item.disabled .page-link {
      color: #95a5a6;
      cursor: not-allowed;
      opacity: 0.6;
    }

    .page-link i {
      font-size: 12px;
    }

    /* 模态框样式 */
    .modal {
      display: none;
      position: fixed;
      z-index: 1050;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
      background-color: rgba(0, 0, 0, 0.5);
      opacity: 0;
      transition: opacity var(--transition-speed);
    }

    .modal.show {
      display: block;
      opacity: 1;
    }

    .modal-dialog {
      max-width: 600px;
      margin: 30px auto;
      transform: translateY(-50px);
      transition: transform var(--transition-speed);
    }

    .modal.show .modal-dialog {
      transform: translateY(0);
    }

    .modal-content {
      background-color: white;
      border-radius: 8px;
      overflow: hidden;
      box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    }

    .modal-header {
      padding: 15px 20px;
      border-bottom: 1px solid #eee;
      display: flex;
      justify-content: space-between;
      align-items: center;
      background-color: #f8f9fa;
    }

    .modal-title {
      font-size: 18px;
      font-weight: 600;
      color: var(--secondary-color);
    }

    .modal-body {
      padding: 20px;
      max-height: 70vh;
      overflow-y: auto;
    }

    .modal-footer {
      padding: 15px 20px;
      border-top: 1px solid #eee;
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      background-color: #f8f9fa;
    }

    .close {
      font-size: 24px;
      font-weight: bold;
      color: #7f8c8d;
      background: none;
      border: none;
      cursor: pointer;
      transition: color var(--transition-speed);
    }

    .close:hover {
      color: var(--danger-color);
    }

    /* 表单样式 */
    .form-group {
      margin-bottom: 20px;
    }

    .form-group label {
      display: block;
      margin-bottom: 8px;
      font-weight: 500;
      color: var(--secondary-color);
    }

    .form-control {
      width: 100%;
      padding: 12px 15px;
      border: 1px solid #ddd;
      border-radius: 6px;
      font-size: 14px;
      transition: all var(--transition-speed);
    }

    .form-control:focus {
      border-color: var(--primary-color);
      box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
      outline: none;
    }

    /* 密码强度指示器 */
    .password-strength {
      margin-top: 10px;
      height: 5px;
      background-color: #eee;
      border-radius: 3px;
      overflow: hidden;
    }

    .password-strength-bar {
      height: 100%;
      width: 0;
      background-color: #ddd;
      transition: width 0.3s, background-color 0.3s;
    }

    /* 动画 */
    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(10px); }
      to { opacity: 1; transform: translateY(0); }
    }

    /* 响应式设计 */
    @media (max-width: 768px) {
      .table th, .table td {
        padding: 12px 8px;
        font-size: 14px;
      }

      .action-buttons {
        flex-direction: column;
        gap: 5px;
      }

      .btn-sm {
        padding: 6px 10px;
        font-size: 12px;
      }

      .modal-dialog {
        margin: 20px auto;
        width: 95%;
      }

      .page-link {
        min-width: 35px;
        height: 35px;
        padding: 0 10px;
        font-size: 13px;
      }
    }
  </style>
  <!-- 引入Font Awesome图标 -->
  <!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">-->
  <link rel="stylesheet" href="../../fontawesome-free-6.7.2-web/css/all.min.css">
</head>
<body>
<div class="main-content">
  <div class="card">
    <div class="card-header">
      <h3>用户管理</h3>
      <button class="btn btn-primary" id="addUserBtn">
        <i class="fas fa-plus"></i> 添加用户
      </button>
    </div>
    <div class="card-body">
      <div class="table-toolbar">
        <div class="search-box">
          <i class="fas fa-search"></i>
          <input type="text" id="userSearch" placeholder="搜索用户...">
        </div>
        <div class="filter-group">
          <select class="filter-select" id="roleFilter">
            <option value="">所有角色</option>
            <option value="admin">管理员</option>
            <option value="editor">编辑员</option>
            <option value="guest">访客</option>
          </select>
          <select class="filter-select" id="statusFilter">
            <option value="">所有状态</option>
            <option value="active">活跃</option>
            <option value="inactive">未激活</option>
            <option value="banned">已封禁</option>
          </select>
        </div>
      </div>

      <div class="table-responsive">
        <table class="table">
          <thead>
          <tr>
            <th>用户名</th>
            <th>邮箱</th>
            <th>角色</th>
            <th>注册时间</th>
            <th>状态</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          <tr>
            <td>
              <div class="user-avatar">
                <img src="https://via.placeholder.com/40" alt="用户头像">
                <span>北极星</span>
              </div>
            </td>
            <td>admin@beijixing.com</td>
            <td><span class="badge badge-primary">管理员</span></td>
            <td>2023-01-15</td>
            <td><span class="badge badge-success">活跃</span></td>
            <td>
              <div class="action-buttons">
                <button class="btn btn-sm btn-primary edit-user-btn" data-user-id="1">
                  <i class="fas fa-edit"></i> 编辑
                </button>
                <button class="btn btn-sm btn-danger delete-user-btn" data-user-id="1">
                  <i class="fas fa-trash"></i> 删除
                </button>
              </div>
            </td>
          </tr>
          <tr>
            <td>
              <div class="user-avatar">
                <img src="https://via.placeholder.com/40" alt="用户头像">
                <span>编辑员</span>
              </div>
            </td>
            <td>editor@beijixing.com</td>
            <td><span class="badge badge-warning">编辑员</span></td>
            <td>2023-05-20</td>
            <td><span class="badge badge-success">活跃</span></td>
            <td>
              <div class="action-buttons">
                <button class="btn btn-sm btn-primary edit-user-btn" data-user-id="2">
                  <i class="fas fa-edit"></i> 编辑
                </button>
                <button class="btn btn-sm btn-danger delete-user-btn" data-user-id="2">
                  <i class="fas fa-trash"></i> 删除
                </button>
              </div>
            </td>
          </tr>
          <tr>
            <td>
              <div class="user-avatar">
                <img src="https://via.placeholder.com/40" alt="用户头像">
                <span>测试用户</span>
              </div>
            </td>
            <td>test@beijixing.com</td>
            <td><span class="badge badge-info">访客</span></td>
            <td>2023-08-10</td>
            <td><span class="badge badge-danger">已封禁</span></td>
            <td>
              <div class="action-buttons">
                <button class="btn btn-sm btn-primary edit-user-btn" data-user-id="3">
                  <i class="fas fa-edit"></i> 编辑
                </button>
                <button class="btn btn-sm btn-danger delete-user-btn" data-user-id="3">
                  <i class="fas fa-trash"></i> 删除
                </button>
              </div>
            </td>
          </tr>
          </tbody>
        </table>
      </div>

      <div class="pagination">
        <ul>
          <li class="page-item disabled">
            <a class="page-link" href="#"><i class="fas fa-angle-left"></i></a>
          </li>
          <li class="page-item active">
            <a class="page-link" href="#">1</a>
          </li>
          <li class="page-item">
            <a class="page-link" href="#">2</a>
          </li>
          <li class="page-item">
            <a class="page-link" href="#">3</a>
          </li>
          <li class="page-item">
            <a class="page-link" href="#">4</a>
          </li>
          <li class="page-item">
            <a class="page-link" href="#">5</a>
          </li>
          <li class="page-item">
            <a class="page-link" href="#"><i class="fas fa-angle-right"></i></a>
          </li>
        </ul>
      </div>
    </div>
  </div>
</div>

<!-- 添加用户模态框 -->
<div class="modal" id="addUserModal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">添加新用户</h5>
        <button type="button" class="close" id="closeAddUserModal">&times;</button>
      </div>
      <div class="modal-body">
        <form id="addUserForm">
          <div class="form-group">
            <label>用户名</label>
            <input type="text" class="form-control" id="username" required>
          </div>
          <div class="form-group">
            <label>邮箱</label>
            <input type="email" class="form-control" id="email" required>
          </div>
          <div class="form-group">
            <label>密码</label>
            <input type="password" class="form-control" id="password" required>
            <div class="password-strength mt-2">
              <div class="password-strength-bar" id="passwordStrengthBar"></div>
            </div>
            <small class="text-muted">密码至少8个字符，包含字母和数字</small>
          </div>
          <div class="form-group">
            <label>确认密码</label>
            <input type="password" class="form-control" id="confirmPassword" required>
          </div>
          <div class="form-group">
            <label>角色</label>
            <select class="form-control" id="role" required>
              <option value="">请选择角色</option>
              <option value="admin">管理员</option>
              <option value="editor">编辑员</option>
              <option value="guest">访客</option>
            </select>
          </div>
          <div class="form-group">
            <label>状态</label>
            <select class="form-control" id="status" required>
              <option value="active">活跃</option>
              <option value="inactive">未激活</option>
              <option value="banned">已封禁</option>
            </select>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" id="cancelAddUser">取消</button>
        <button type="button" class="btn btn-primary" id="submitAddUser">添加用户</button>
      </div>
    </div>
  </div>
</div>

<!-- 编辑用户模态框 -->
<div class="modal" id="editUserModal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">编辑用户</h5>
        <button type="button" class="close" id="closeEditUserModal">&times;</button>
      </div>
      <div class="modal-body">
        <form id="editUserForm">
          <input type="hidden" id="editUserId">
          <div class="form-group">
            <label>用户名</label>
            <input type="text" class="form-control" id="editUsername" required>
          </div>
          <div class="form-group">
            <label>邮箱</label>
            <input type="email" class="form-control" id="editEmail" required>
          </div>
          <div class="form-group">
            <label>角色</label>
            <select class="form-control" id="editRole" required>
              <option value="admin">管理员</option>
              <option value="editor">编辑员</option>
              <option value="guest">访客</option>
            </select>
          </div>
          <div class="form-group">
            <label>状态</label>
            <select class="form-control" id="editStatus" required>
              <option value="active">活跃</option>
              <option value="inactive">未激活</option>
              <option value="banned">已封禁</option>
            </select>
          </div>
          <div class="form-group">
            <div class="form-check">
              <input type="checkbox" class="form-check-input" id="changePasswordCheck">
              <label class="form-check-label" for="changePasswordCheck">更改密码</label>
            </div>
          </div>
          <div class="password-fields" style="display: none;">
            <div class="form-group">
              <label>新密码</label>
              <input type="password" class="form-control" id="editPassword">
            </div>
            <div class="form-group">
              <label>确认新密码</label>
              <input type="password" class="form-control" id="editConfirmPassword">
            </div>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" id="cancelEditUser">取消</button>
        <button type="button" class="btn btn-primary" id="submitEditUser">保存更改</button>
      </div>
    </div>
  </div>
</div>

<!-- 删除确认模态框 -->
<div class="modal" id="confirmDeleteModal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">确认删除</h5>
        <button type="button" class="close" id="closeDeleteModal">&times;</button>
      </div>
      <div class="modal-body">
        <p>您确定要删除此用户吗？此操作无法撤销。</p>
        <input type="hidden" id="deleteUserId">
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" id="cancelDelete">取消</button>
        <button type="button" class="btn btn-danger" id="confirmDelete">确认删除</button>
      </div>
    </div>
  </div>
</div>

<script>
  // 显示添加用户模态框
  document.getElementById('addUserBtn').addEventListener('click', function() {
    document.getElementById('addUserModal').classList.add('show');
    document.body.style.overflow = 'hidden';
  });

  // 关闭模态框的函数
  function closeModal(modal) {
    modal.classList.remove('show');
    document.body.style.overflow = '';
  }

  // 关闭添加用户模态框
  document.getElementById('closeAddUserModal').addEventListener('click', () => closeModal(document.getElementById('addUserModal')));
  document.getElementById('cancelAddUser').addEventListener('click', () => closeModal(document.getElementById('addUserModal')));

  // 提交添加用户表单
  document.getElementById('submitAddUser').addEventListener('click', function() {
    const password = document.getElementById('password').value;
    const confirmPassword = document.getElementById('confirmPassword').value;

    if (password !== confirmPassword) {
      alert('两次输入的密码不一致！');
      return;
    }

    // 这里应该处理表单提交
    alert('用户添加成功！');
    closeModal(document.getElementById('addUserModal'));
    document.getElementById('addUserForm').reset();
  });

  // 密码强度检测
  document.getElementById('password').addEventListener('input', function() {
    const password = this.value;
    const strengthBar = document.getElementById('passwordStrengthBar');
    let strength = 0;

    if (password.length >= 8) strength += 1;
    if (password.match(/[a-z]/)) strength += 1;
    if (password.match(/[A-Z]/)) strength += 1;
    if (password.match(/[0-9]/)) strength += 1;
    if (password.match(/[^a-zA-Z0-9]/)) strength += 1;

    const width = (strength / 5) * 100;
    strengthBar.style.width = width + '%';

    if (strength <= 2) {
      strengthBar.style.backgroundColor = '#e74c3c';
    } else if (strength <= 4) {
      strengthBar.style.backgroundColor = '#f39c12';
    } else {
      strengthBar.style.backgroundColor = '#2ecc71';
    }
  });

  // 编辑用户功能
  document.querySelectorAll('.edit-user-btn').forEach(btn => {
    btn.addEventListener('click', function() {
      const userId = this.getAttribute('data-user-id');
      // 这里应该获取用户数据并填充表单
      document.getElementById('editUserId').value = userId;

      // 模拟获取用户数据
      let username, email, role, status;
      if (userId === '1') {
        username = '北极星';
        email = 'admin@beijixing.com';
        role = 'admin';
        status = 'active';
      } else if (userId === '2') {
        username = '编辑员';
        email = 'editor@beijixing.com';
        role = 'editor';
        status = 'active';
      } else {
        username = '测试用户';
        email = 'test@beijixing.com';
        role = 'guest';
        status = 'banned';
      }

      document.getElementById('editUsername').value = username;
      document.getElementById('editEmail').value = email;
      document.getElementById('editRole').value = role;
      document.getElementById('editStatus').value = status;

      document.getElementById('editUserModal').classList.add('show');
      document.body.style.overflow = 'hidden';
    });
  });

  // 关闭编辑用户模态框
  document.getElementById('closeEditUserModal').addEventListener('click', () => closeModal(document.getElementById('editUserModal')));
  document.getElementById('cancelEditUser').addEventListener('click', () => closeModal(document.getElementById('editUserModal')));

  // 提交编辑用户表单
  document.getElementById('submitEditUser').addEventListener('click', function() {
    const userId = document.getElementById('editUserId').value;
    const changePassword = document.getElementById('changePasswordCheck').checked;

    if (changePassword) {
      const password = document.getElementById('editPassword').value;
      const confirmPassword = document.getElementById('editConfirmPassword').value;

      if (password !== confirmPassword) {
        alert('两次输入的密码不一致！');
        return;
      }
    }

    // 这里应该处理表单提交
    alert('用户信息已更新！');
    closeModal(document.getElementById('editUserModal'));
  });

  // 显示/隐藏密码字段
  document.getElementById('changePasswordCheck').addEventListener('change', function() {
    const passwordFields = document.querySelector('.password-fields');
    if (this.checked) {
      passwordFields.style.display = 'block';
    } else {
      passwordFields.style.display = 'none';
    }
  });

  // 删除用户功能
  document.querySelectorAll('.delete-user-btn').forEach(btn => {
    btn.addEventListener('click', function() {
      const userId = this.getAttribute('data-user-id');
      document.getElementById('deleteUserId').value = userId;
      document.getElementById('confirmDeleteModal').classList.add('show');
      document.body.style.overflow = 'hidden';
    });
  });

  // 关闭删除确认模态框
  document.getElementById('closeDeleteModal').addEventListener('click', () => closeModal(document.getElementById('confirmDeleteModal')));
  document.getElementById('cancelDelete').addEventListener('click', () => closeModal(document.getElementById('confirmDeleteModal')));

  // 确认删除
  document.getElementById('confirmDelete').addEventListener('click', function() {
    const userId = document.getElementById('deleteUserId').value;
    // 这里应该处理删除逻辑
    alert(`用户ID ${userId} 已删除！`);
    closeModal(document.getElementById('confirmDeleteModal'));
  });

  // 搜索功能
  document.getElementById('userSearch').addEventListener('input', function() {
    const searchTerm = this.value.toLowerCase();
    document.querySelectorAll('.table tbody tr').forEach(row => {
      const username = row.querySelector('.user-avatar span').textContent.toLowerCase();
      const email = row.cells[1].textContent.toLowerCase();
      if (username.includes(searchTerm) || email.includes(searchTerm)) {
        row.style.display = '';
      } else {
        row.style.display = 'none';
      }
    });
  });

  // 筛选功能
  document.getElementById('roleFilter').addEventListener('change', filterUsers);
  document.getElementById('statusFilter').addEventListener('change', filterUsers);

  function filterUsers() {
    const roleFilter = document.getElementById('roleFilter').value;
    const statusFilter = document.getElementById('statusFilter').value;

    document.querySelectorAll('.table tbody tr').forEach(row => {
      const role = row.cells[2].textContent.toLowerCase();
      const status = row.cells[4].textContent.toLowerCase();

      const roleMatch = !roleFilter || role.includes(roleFilter);
      const statusMatch = !statusFilter || status.includes(statusFilter);

      if (roleMatch && statusMatch) {
        row.style.display = '';
      } else {
        row.style.display = 'none';
      }
    });
  }

  // 点击模态框外部关闭
  window.addEventListener('click', (e) => {
    if (e.target === document.getElementById('addUserModal')) {
      closeModal(document.getElementById('addUserModal'));
    }
    if (e.target === document.getElementById('editUserModal')) {
      closeModal(document.getElementById('editUserModal'));
    }
    if (e.target === document.getElementById('confirmDeleteModal')) {
      closeModal(document.getElementById('confirmDeleteModal'));
    }
  });

  // 按ESC键关闭模态框
  document.addEventListener('keydown', (e) => {
    if (e.key === 'Escape') {
      if (document.getElementById('addUserModal').classList.contains('show')) {
        closeModal(document.getElementById('addUserModal'));
      }
      if (document.getElementById('editUserModal').classList.contains('show')) {
        closeModal(document.getElementById('editUserModal'));
      }
      if (document.getElementById('confirmDeleteModal').classList.contains('show')) {
        closeModal(document.getElementById('confirmDeleteModal'));
      }
    }
  });
</script>
</body>
</html>